#pragma once

#include <time.h>
#include <stdio.h>
#include <stdlib.h>


#define TIMEOUT 60
#define HSAHSEED 61

typedef struct time_node
{
    int fd;
    time_t t;
    struct time_node* next;
} time_node_t;

// 时间队列
typedef struct
{
    time_node_t* arr[TIMEOUT];
} time_queue_t;

// hash 表
typedef struct
{
    time_node_t* arr[HSAHSEED];
} time_hash_t;


// 创建时间队列

// 入队
int insert_time_queue(time_queue_t* time_queue, int fd, time_t t);

// 入 hash 表
int insert_time_hash(time_hash_t* hash, int fd, time_t t);

// 超时剔除
int overtime_eliminate_time_queue(time_queue_t* time_queue, time_hash_t* hash, time_t t, int epoll_fd);
int eliminate_time_hash(time_hash_t* hash, int fd);
int eliminate_time_queue(time_queue_t* time_queue, int fd, time_t t);

// 查找
int find_time_hash(time_hash_t* hash, int fd, time_t* t);

// 移动
int move_time_queue(time_queue_t* time_queue, int fd, time_t old_t, time_t new_t);

int update_time_hash(time_hash_t* hash, int fd, time_t new_t);



